package 寒假刷题;

public class 可以形成最大正方形的数目 {
    public int countGoodRectangles1(int[][] rectangles) {
        int max = 0,ans = 0;
        for (int[] v : rectangles) {
            int cur = Math.min(v[0],v[1]);
            if (cur==max)
                ans++;
            else if (cur>max){
                max = cur;
                ans = 1;
            }
        }
        return ans;
    }
    public int countGoodRectangles(int[][] rectangles) {
        int n = rectangles.length;
        int max = 0;
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            int[] ints = rectangles[i];
            ans[i] = Math.min(ints[0],ints[1]);
            max = Math.max(max,ans[i]);
        }
        int res = 0;
        for (int i = 0; i < n; i++) {
            if (ans[i]>=max)
                res++;
        }
        return res;
    }
}
